package com.uzai.console.vo.wechatprivate.friendrequest;

import com.uzai.console.enums.FriendRequestScene;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.ObjectUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liuqi
 * @date 2021年09月01日 18:06
 */
@ApiModel("好友请求统计项对象")
@Data
public class FriendRequestCountItemVo {

    @ApiModelProperty("机器人唯一id")
    private Long deviceUniqueId;

    @ApiModelProperty("机器人备注")
    private String deviceRemark;

    @ApiModelProperty("机器人名称")
    private String deviceName;

    @ApiModelProperty("所有机器人的人数综合")
    private Integer count = 0;

    @ApiModelProperty("申请总数")
    private Integer applyCount = 0;

    @ApiModelProperty("通过总数")
    private Integer passCount = 0;

    @ApiModelProperty("是否在线, 0: 不在线, 1: 在线")
    private Integer online;

    @ApiModelProperty("场景人数列表")
    private List<SceneInfo> sceneList = new ArrayList<>();

    public static SceneInfo sceneInfo(Integer scene, Integer count) {
        SceneInfo sceneInfo = new SceneInfo();
        sceneInfo.setScene(scene);
        sceneInfo.setCount(count);
        sceneInfo.setSceneName(ObjectUtils.defaultIfNull(FriendRequestScene.getById(scene), FriendRequestScene.UN_KNOW).getLabel());
        return sceneInfo;
    }

    public static SceneInfo sceneInfo(Integer scene, String sceneName, Integer count) {
        SceneInfo sceneInfo = new SceneInfo();
        sceneInfo.setScene(scene);
        sceneInfo.setCount(count);
        sceneInfo.setSceneName(sceneName);
        return sceneInfo;
    }

    public Integer calculateTotal() {
        int result = 0;
        for (SceneInfo sceneInfo : sceneList) {
            result += sceneInfo.getCount();
        }
        count = result;
        return result;
    }

    @ApiModel("场景信息")
    @Data
    public static class SceneInfo {

        @ApiModelProperty("请求添加好友的来源(17-个人微信卡片添加；14-个人微信群内添加；30个人微信扫描二维码添加；3个人微信搜索微信号添加; 1-企业微信扫描二维码添加；2-通过手机号搜索添加；3-好友分享名片添加；4-通过群添加)")
        private Integer scene;

        @ApiModelProperty("人数")
        private Integer count;

        @ApiModelProperty("来源名")
        private String sceneName;
    }
}
